//
//  DCRequestSerializer.m
//  HappyChat
//
//  Created by guduzhonglao on 10/4/19.
//  Copyright © 2019 onlysea. All rights reserved.
//

#import "DCRequestSerializer.h"

@interface DCRequestSerializer ()

@property(nonatomic,strong) dispatch_queue_t kvoQueue;

@end

@implementation DCRequestSerializer

+ (instancetype)serializer{
    DCRequestSerializer* request = [super serializer];
    if (request) {
        request.kvoQueue = dispatch_queue_create("AFN.request.kvo", NULL);
    }
    return request;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if (self.kvoQueue) {
        dispatch_async(self.kvoQueue, ^{
            [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
        });
    } else {
        [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
    }
}

@end
